package com.yanqu.road.server.cmd.activity;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ActivityProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.PlayerModule;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_SYSTEM_REMAIN_TIME_LOG, desc = "系统逗留时间记录")
public class SystemRemainTimeLogCmd extends AbstractCommand {

	private ActivityProto.SystemRemainTimeMsg reqMsg;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		reqMsg = ActivityProto.SystemRemainTimeMsg.parseFrom(packet.getBytes());
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		if (player == null) {
			return;
		}
		PlayerModule playerModule = player.getModule(PlayerModule.class);
		for(ActivityProto.SystemRemainTimeTemp data : reqMsg.getRemainTimeListList()){
			playerModule.addSystemRemainTime(data.getSystem(), data.getRemainTime());
		}
	}

	@Override
	public void sendData(GamePlayer player) {

	}

}
